package com.czy;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws InterruptedException, IOException {
        System.out.println("输入要读取的文件: ");
        Scanner scanner = new Scanner(System.in);
        File file = new File(scanner.nextLine());

        try (BufferedReader br = new BufferedReader(new FileReader(file))){
            System.out.println("输入要搜索的内容: ");
            String content = scanner.nextLine();
            String s;
            int num = 0;
            while ((s = br.readLine()) != null) {
                if(s.contains(content)) {
                    num++;
                    System.out.println(s);
                }
            }
            System.out.println(num == 0 ? "未找到" : "找到 " + num + " 个");
        }
    }
}
